home *** CD-ROM | disk | FTP | other *** search
- /*****
- * sortWindow.c
- *
- *
- *****/
- #include <Quickdraw.h>
- #include <Dialogs.h>
- #include <OSUtils.h>
-
- #ifdef THINK_C
- #include <Think.h>
- #endif /* THINK_C */
-
- #include "sortWindow.h"
- #include "sortMenus.h"
- #include "sort.h"
-
- WindowPtr sortWindow;
- Rect dragRect;
- Rect windowBounds;
- Rect r;
- short height;
- Boolean sorting;
-
- /****
- * SetUpWindow()
- *
- * Create the sort window, and open it.
- *
- ****/
-
- void SetUpWindow(void)
-
- {
- #ifdef THINK_C
- windowBounds = screenBits.bounds;
- #else /* applec */
- windowBounds = qd.screenBits.bounds;
- #endif /* applec */
-
- windowBounds.top += 20;
-
- sortWindow = NewWindow(0L, &windowBounds, "\pSort", true, plainDBox, (WindowPtr) -1L, true, 0);
- SetPort(sortWindow);
-
- height=(((windowBounds.bottom - windowBounds.top) - numdataitems)) / (numdataitems + 1);
-
- }
- /* end SetUpWindow */
-
-
- /*****
- * Drawsort()
- *
- * Draws the sort.
- *
- *****/
-
- void DrawSort(short active)
- {
- #pragma unused (active)
- long count;
-
- if (((WindowPeek) sortWindow)->visible) {
- SetPort(sortWindow);
- for (count = 0; count < numdataitems; count++) {
- eraseitem(count);
- drawitem(count);
- }
- }
-
- }
- /* end Drawsort */
-
- void myHilite(long item)
- {
- WindowPtr w;
-
- if ((((WindowPeek) sortWindow)->visible)) {
- GetPort(&w);
- SetPort(sortWindow);
-
- r.left = 5;
- r.top = item * (height + 1) + 5;
- r.right = sortdata[item] + r.left;
- r.bottom = r.top + height;
- PaintRoundRect(&r, height, height);
- SetPort(w);
- }
- }
-
- void unhilite(long item)
- {
- WindowPtr w;
-
- if ((((WindowPeek) sortWindow)->visible)) {
- GetPort(&w);
- SetPort(sortWindow);
-
- r.left = 5;
- r.top = item * (height + 1) + 5;
- r.right = sortdata[item] + r.left;
- r.bottom = r.top + height;
- EraseRoundRect(&r, height, height);
- FrameRoundRect(&r, height, height);
- SetPort(w);
- }
- }
-
- void drawitem(long item)
- {
- WindowPtr w;
-
- if (((WindowPeek) sortWindow)->visible) {
- GetPort(&w);
- SetPort(sortWindow);
-
- r.left = 5;
- r.top = item * (height + 1) + 5;
- r.right = sortdata[item] + r.left;
- r.bottom = r.top + height;
- FrameRoundRect(&r, height, height);
- SetPort(w);
- }
- }
-
-
-
- void eraseitem(long item)
- {
- WindowPtr w;
-
- if (((WindowPeek) sortWindow)->visible) {
- GetPort(&w);
- SetPort(sortWindow);
-
- r.left = 5;
- r.top = item * (height + 1) + 5;
- r.right = sortdata[item] + r.left;
- r.bottom = r.top + height;
- EraseRoundRect(&r, height, height);
- SetPort(w);
- }
- }
-
- void do_hilitedelay()
- {
- long dummy;
-
- if ((((WindowPeek) sortWindow)->visible) && (!stop_sort)) {
- Delay(hilitedelay, &dummy);
- }
- }
-
- void do_unhilitedelay()
- {
- long dummy;
-
- if ((((WindowPeek) sortWindow)->visible) && (!stop_sort)) {
- Delay(unhilitedelay, &dummy);
- }
- }